#ifndef CUDP_H
#define CUDP_H

#include <QObject>
#include "QUdpSocket"



class CUdp : public QObject
{
    Q_OBJECT
public:
    explicit CUdp(QObject *parent = nullptr);
    ~CUdp();
    enum EnmState{
        ENM_NOT_READY = 0,
        ENM_READYED,
        ENM_CONNECTED,
    };
    virtual bool startConnection(void *pInfo);
    virtual void stopConnection(); //断开连接 或 停止监听
    virtual int sendAll(QByteArray byteArr);
    virtual int send(QString strIp,quint16 nPort,QByteArray byteArr);
    virtual QString errorString();
    QUdpSocket *m_pUdp = nullptr;



signals:
    void sigStateChanged(EnmState enmState); //未连接
    void sigConnectChanged(QString strIp,quint16 nPort,bool bState);
    void sigReadyRead(QIODevice *pIODevice); //外部进行类型转换 串口和Tcp Udp有不同的数据读法
    void sigDataArrive(QString strIp,quint16 nPort,QByteArray byteArr);
    void sigSend(QByteArray &byteArr);


};

#endif // CUDP_H
